package o;

import android.content.Context;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.infoflow.cards.bean.BaseInfoFlowCardBean;
import com.huawei.appmarket.service.infoflow.cards.bean.RefreshInfoCardBean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import o.dky.j;

public class eae extends chl {
    private chz ˋ;
    private BaseInfoFlowCardBean ˏ;
    private chz ॱ;

    public eae(Context context) {
        super(context);
        ʼॱ();
    }

    public boolean ˏ() {
        return this.ॱॱ.size() > 1;
    }

    public void ˊ() {
        ˊ(this.ॱ);
        this.ॱॱ.add(0, this.ॱ);
    }

    public boolean ˋ() {
        return this.ॱॱ.contains(this.ॱ);
    }

    public void ˎ() {
        if (ˊॱ() > 502) {
            Collection arrayList = new ArrayList();
            int i = 0;
            for (chz o_chz : this.ॱॱ) {
                int ॱ = ॱ(o_chz);
                i += ॱ;
                if (i < 502) {
                    arrayList.add(o_chz);
                } else {
                    i = (501 - (i - ॱ)) * o_chz.ˋ.ˏ();
                    if (i > 0) {
                        Collection arrayList2 = new ArrayList(o_chz.ˏ().subList(0, i));
                        o_chz.ˏ().clear();
                        o_chz.ˏ().addAll(arrayList2);
                        arrayList.add(o_chz);
                    }
                    this.ॱॱ.clear();
                    this.ॱॱ.addAll(arrayList);
                    this.ॱॱ.add(this.ˋ);
                }
            }
            this.ॱॱ.clear();
            this.ॱॱ.addAll(arrayList);
            this.ॱॱ.add(this.ˋ);
        }
    }

    public void ॱˎ() {
        int size = this.ॱॱ.size();
        if (size > 1) {
            CardBean ˎ = ((chz) this.ॱॱ.get(size - 2)).ˎ();
            if (ˎ instanceof BaseInfoFlowCardBean) {
                ((BaseInfoFlowCardBean) ˎ).ॱ(false);
            }
        }
    }

    public void ᐝॱ() {
        if (this.ॱॱ.isEmpty()) {
            this.ॱॱ.add(this.ˋ);
        }
    }

    public void ˏ(boolean z) {
    }

    public void ˎ(boolean z, boolean z2) {
    }

    public void ˊ(chz o_chz, List<CardBean> list) {
        if (o_chz != null && !list.isEmpty()) {
            if (this.ˏ != null) {
                this.ˏ.ॱ(true);
            }
            CardBean cardBean = (CardBean) list.get(list.size() - 1);
            if (cardBean instanceof BaseInfoFlowCardBean) {
                BaseInfoFlowCardBean baseInfoFlowCardBean = (BaseInfoFlowCardBean) cardBean;
                baseInfoFlowCardBean.ॱ(false);
                this.ˏ = baseInfoFlowCardBean;
            }
        }
    }

    private void ʼॱ() {
        ˈ();
    }

    private void ˊ(chz o_chz) {
        if (!this.ॱॱ.isEmpty() && this.ॱॱ.contains(o_chz)) {
            this.ॱॱ.remove(o_chz);
        }
    }

    private void ˈ() {
        int ˏ = cib.ˏ("refreshinfocard");
        RefreshInfoCardBean refreshInfoCardBean = new RefreshInfoCardBean();
        refreshInfoCardBean.ʼ(j.ʼॱ);
        List arrayList = new ArrayList();
        arrayList.add(refreshInfoCardBean);
        this.ॱ = ˎ((long) 10101, ˏ, arrayList);
        refreshInfoCardBean = new RefreshInfoCardBean();
        refreshInfoCardBean.ʼ(j.ʽॱ);
        arrayList = new ArrayList();
        arrayList.add(refreshInfoCardBean);
        this.ˋ = ˎ((long) 10101, ˏ, arrayList);
    }

    private chz ˎ(long j, int i, List<CardBean> list) {
        chz o_chz = new chz(j, cib.ˋ(this.ʼ, i), 1, list);
        int i2 = this.ͺ;
        this.ͺ = i2 + 1;
        o_chz.ˊ(i2);
        return o_chz;
    }
}
